package com.sign2024.sign2024project.signBase.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sign2024.sign2024core.common.CommonResult;
import com.sign2024.sign2024core.common.annotation.Log;
import com.sign2024.sign2024project.signBase.entry.BaseDisclose;
import com.sign2024.sign2024project.signBase.param.BaseDiscloseParam;
import com.sign2024.sign2024project.signBase.service.BaseDiscloseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author yujie
 * @data 2024/11/27 9:24
 */
@Api(tags = "评标基地")
@RestController
@RequestMapping("/api/baseDisclose")
public class BaseDiscloseController {

    @Resource
    private BaseDiscloseService baseDiscloseService;

    @Log(title = "评标基地", businessType = "添加")
    @ApiOperation(value = "添加基地信息", notes = "添加基地信息")
    @PostMapping("/add")
    public CommonResult add(BaseDisclose baseDisclose) {
        baseDiscloseService.insertBaseDisclose(baseDisclose);
        return CommonResult.success();
    }

    @Log(title = "评标基地", businessType = "更新")
    @ApiOperation(value = "修改基地信息", notes = "修改基地信息")
    @PostMapping("/save")
    public CommonResult saveDefault(BaseDisclose baseDisclose) {
        baseDiscloseService.updateBaseDisclose(baseDisclose);
        return CommonResult.success();
    }

    @Log(title = "评标基地", businessType = "查询")
    @ApiOperation(value = "分页查询评标基地信息", notes = "分页查询评标基地信息")
    @PostMapping("/page")
    public CommonResult<BaseDisclose> page(BaseDiscloseParam param) {
        Page<BaseDisclose> page = baseDiscloseService.pageBaseDisclose(param);
        return CommonResult.success(page);
    }

    @Log(title = "评标基地", businessType = "查询")
    @ApiOperation(value = "基地信息列表", notes = "基地信息列表")
    @PostMapping("/selectByName")
    public CommonResult selectByName() {
        List<String> list = baseDiscloseService.selectNameList();
        return CommonResult.success(list);
    }
}
